package initialize

import (
	modbus "github.com/thinkgos/gomodbus"
	"github.com/thinkgos/gomodbus/mb"
	"time"

	"meinong/hardware/global"
)

func InitCalculatorHead(Address string){

	p:=modbus.NewRTUClientProvider()

	p.Address = Address

	p.BaudRate = 9600

	p.DataBits = 8

	p.Parity = "N"

	p.StopBits = 1

	p.Timeout = 100 * time.Millisecond

	global.ModbusClientHead = mb.NewClient(p)

	global.ModbusClientHead.LogMode(false)

	err := global.ModbusClientHead.Start()

	if err != nil {
		panic(err)
	}


}
func InitCalculatorTail(Address string){

	p:=modbus.NewRTUClientProvider()

	p.Address = Address

	p.BaudRate = 9600

	p.DataBits = 8

	p.Parity = "N"

	p.StopBits = 1

	p.Timeout = 100 * time.Millisecond

	global.ModbusClientTail =mb.NewClient(p)

	global.ModbusClientTail.LogMode(false)

	err := global.ModbusClientTail.Start()

	if err != nil {
		panic(err)
	}


}
